//
//  HomeRecommendView.swift
//  HomeRecommendView
//
//  Created by Ben on 2021/8/19.
//

import SwiftUI

struct HomeRecommendView: View {
    @EnvironmentObject var homeVM: HomeViewModel

    var body: some View {
        
        GeometryReader { proxy in
            
            ScrollView(.vertical, showsIndicators: false) {
                VStack(spacing: 0) {
                    VStack(spacing: 10) {
                        // 闲鱼优品
                        HomeRecommendHightQualityView()
                            .padding(8)
                            .background(
                                RoundedRectangle(cornerRadius: 10)
                                    .fill(Color(hex: 0xF9FAFB))
                            )
                            
                        // 其他快捷入口
                        HomeRecommendQuickIntoView()
                            .padding(8)
                            .background(
                                RoundedRectangle(cornerRadius: 10)
                                    .fill(Color(hex: 0xF9FAFB))
                            )
                    }
                    .padding(.horizontal, 16)
                    
                    // 不同分类的二手商品信息
                    HomeRecommendGoodsView()
                    
                }
            }
            .onAppear {
                let maxY = proxy.frame(in: .global).minY
                
                DispatchQueue.main.async {
                    if homeVM.homeRecommendMinY == 0 {
                        homeVM.homeRecommendMinY = maxY
                    }
                }
            }
        }
        
       
        
    }
}
